import 'package:architecture/ext_string.dart';
import 'package:architecture/os_size.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:shake_animation_widget/shake_animation_widget.dart';
import 'package:study_demo/ui/auto_update/auto_update_page.dart';
import 'package:study_demo/ui/device_info/device_info_page.dart';
import 'package:study_demo/ui/ffi/ffi_page.dart';
import 'package:study_demo/ui/main/controller.dart';
import 'package:study_demo/ui/shader/shader_page_plus.dart';
import 'package:study_demo/ui/shader/shaders_list.dart';
import 'package:study_demo/widgets/navi.dart';
import 'package:study_demo/widgets/text_button.dart';
import '../az_list/az_list_page.dart';
import '../countdown/countdown_page.dart';
import '../flow_layout/flow_page.dart';
import '../relax/relax_page.dart';
import '../shader/shader_widget.dart';
import '../shimmer/shimmer_page.dart';
import '../slide/slide_page.dart';
import '../verification_code/verification_code_page.dart';

class MainPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return GetBuilder<MainController>(
        init: MainController(),
        builder: (controller) {
          return Scaffold(
              // backgroundColor: Colors.white,
              body: Container(
                  //     decoration: BoxDecoration(
                  //     image: DecorationImage(
                  //     image: AssetImage("assets/images/home_bg.jpg"),
                  // fit: BoxFit.fill),
                  // ),
                  child: Row(children: [
            navi(controller),
            Expanded(
                child: Obx(() => controller.layoutType.value == 0
                    ? right(controller)
                    : controller.widgets[controller.layoutType.value - 1]))
          ])));
        });
  }

  navi(MainController controller) {
    return Container(
        width: windowWidth * 0.08,
        height: windowHeight,
        child: Navi(
          controller.icons,
          controller.data,
          onPressed: (value) {
            controller.changeLayout(value);
          },
        ));
  }

  right(MainController controller) {
    return Stack(
      children: [
        // ShaderWidget(shaderName: 'snow.frag'),
        Column(
          children: [
            Container(
              margin: EdgeInsets.only(top: 20),
              alignment: Alignment.centerLeft,
              child: Wrap(
                  alignment: WrapAlignment.start,
                  crossAxisAlignment: WrapCrossAlignment.start,
                  spacing: 20,
                  runSpacing: 20,
                  children: [
                    MyTextButton(
                      text: 'countdown_time'.translate(),
                      confirm: () {
                        Get.to(CountDownPage());
                      },
                    ),
                    MyTextButton(
                      text: "flow_layout".translate(),
                      confirm: () {
                        Get.to(FlowlayoutPage());
                      },
                    ),
                    // MyTextButton(
                    //   text: "播放视频",
                    //   confirm: () {
                    //     Get.to(VideoPlayerPage());
                    //   },
                    // ),
                    // MyTextButton(
                    //   text: "省市区",
                    //   confirm: () {
                    //     // controller.chooseCity(context);
                    //   },
                    // ),
                    MyTextButton(
                      text: 'verification_code_input'.translate(),
                      confirm: () {
                        Get.to(VerificationCodePage());
                      },
                    ),
                    MyTextButton(
                      text: 'slide_delete'.translate(),
                      confirm: () {
                        Get.to(SlidePage());
                      },
                    ),

                    // MyTextButton(
                    //   text: "Canvas",
                    //   confirm: () {
                    //     Get.to(CanvasPage());
                    //   },
                    // ),
                    ShakeAnimationWidget(
                        shakeAnimationController:
                            controller.shakeAnimationController,
                        isForward: false,
                        shakeAnimationType: ShakeAnimationType.LeftRightShake,
                        child: MyTextButton(
                          text: 'shake_effect'.translate(),
                          confirm: () {
                            ///开启抖动动画
                            ///参数shakeCount 用来配置抖动次数
                            ///通过 controller start 方法默认为 1
                            controller.shakeAnimationController
                                .start(shakeCount: 1);
                          },
                        )),
                    MyTextButton(
                      text: "Shimmer",
                      confirm: () {
                        Get.to(ShimmerPage());
                      },
                    ),
                    // MyTextButton(
                    //   text: "A-Z索引",
                    //   confirm: () {
                    //     Get.to(AzListPage());
                    //   },
                    // ),
                    MyTextButton(
                      text: 'az_index'.translate(),
                      confirm: () {
                        Get.to(AzListPage());
                      },
                    ),
                    // !isWeb()
                    //     ? MyTextButton(
                    //         text: 'relax_a_while'.translate(),
                    //         confirm: () {
                    //           Get.to(RelaxPage());
                    //         },
                    //       )
                    //     : SizedBox(),
                    MyTextButton(
                      text: '设备信息',
                      confirm: () {
                        Get.to(DeviceInfoPage());
                      },
                    ),
                    // Offstage(
                    //     offstage: isWindows(),
                    //     child: MyTextButton(
                    //       text: "flutter ffi",
                    //       confirm: () {
                    //         Get.to(FFiPage());
                    //       },
                    //     )),
                    MyTextButton(
                      text: 'shader',
                      confirm: () {
                        Get.to(ShadersList());
                      },
                    ),
                    MyTextButton(
                      text: '自动更新',
                      confirm: () {
                        Get.to(AutoUpdatePage());
                      },
                    ),
                    MyTextButton(
                      text: '多窗口',
                      confirm: () {
                        Get.to(AutoUpdatePage());
                      },
                    ),
                  ]),
            ),
          ],
        ),
      ],
    );
  }
}
